/*
 * Copyright (C) 2015  Nicola Spanti (RyDroid) <dev@nicola-spanti.info>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */


/**
 * @file
 * @brief Structure of 2D size and functions to manage it.
 */


#ifndef PLANET_WARS_2D_RT_CORE_SIZE_2D_UINT_H
#define PLANET_WARS_2D_RT_CORE_SIZE_2D_UINT_H


#include "PlanetWars2dRT-core/utils/c_language.h"
#include "PlanetWars2dRT-core/utils/c_type_aliases.h"
#include "PlanetWars2dRT-core/utils/bool.h"
#include "PlanetWars2dRT-core/utils/size_2d_generic.h"


DEFINE_SIZE_2D_STRUCT(uint)


EXTERN_C_BEGIN


/**
 * @brief Returns true if 2 2D sizes of unsigned int are equal, otherwise false.
 * @param size1 A first size
 * @param size2 A second size
 * @return True if 2 2D sizes of unsigned int are equal, otherwise false
 */
static inline
bool
size_2d_uint_equals(const size_2d_uint* size1,
			const size_2d_uint* size2)
{
  return SIZE_2D_EQUALS(*size1, *size2);
}

/**
 * @brief Swap the x member and the y member of a 2D size of unsigned int.
 * @param size A 2D size of unsigned int
 */
static inline
void
size_2d_uint_swap(size_2d_uint* size)
{
  unsigned int tmp = size->x;
  size->x = size->y;
  size->y = tmp;
}

/**
 * @brief Returns the geometric aera of a 2D uint size.
 * @param size A size
 * @return The geometric aera of a 2D uint size
 */
static inline
unsigned int
size_2d_uint_area(const size_2d_uint* size)
{
  return SIZE_2D_AREA(*size);
}


EXTERN_C_END


#endif
